// pages/team/index.js
var util = require('../../utils/util.js');
let app = getApp();
let url = app.url;
let gobalData = app.gobalData;
Page({

  /**
   * 页面的初始数据
   */
  data: {
		groupNumber: 0,
		showModal: false,
		teamDetailList: [],
		id: "",
		count: "",
		address: "",
		picture: "",      //封面
		groupFoundId: null,   //  文章id(大概)
		groupActivityId: null,  // 文章主键（大概）
		isTema: 0,     //判断是否为好友邀请来的
		leaderId: null  //预留接口
  },
	queryTotal(){
		util(`${url}groupFound/getGroupFoundDetail`, {groupFoundId: this.data.id, total: 1}).then(res=>{
			if (res.status == 1){
				this.setData({
					teamDetailList: res.content.contentList
				})
			} else {
				wx.showToast({
					title: res.msg,
					icon: "none"
				})
			}
		})
	},
	// 默认登录之后的毛坯验房成功之后的回调
	temaTrue(e){
		this.setData({
			showModal: true
		})
		// console.log('啦啦啦')
	},
	// 邀请者组团成功
	teamFlagTrue(){
		this.setData({
			showModal: false
		})
		util(`${url}groupFound/getGroupFoundDetail`, {groupFoundId: this.data.id}).then(res=>{
			if (res.status == 1){
				this.setData({
					count: res.content.count,
					teamDetailList: res.content.contentList,
					address: res.content.address
				})
			} else {
				wx.showToast({
					title: res.msg,
					icon: "none"
				})
			}
		})
	},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
		console.log('进入页面获取到的数据：', options);
		this.setData({
			id: options.groupFoundId,
			groupFoundId: options.groupFoundId,
			isTema: options.isTema,
			groupActivityId: options.groupActivityId,
			leaderId: options.leaderId
		})
		util(`${url}GroupActivity/getGroupActivityDetail`).then(res=>{
			if (res.status == 1) {
				this.setData({
					groupNumber: res.content.groupNumber,
					picture: res.content.picture
				})
			} else {
				wx.showToast({
					title: res.msg,
					icon: "none"
				})
			}
		})
		
		util(`${url}groupFound/getGroupFoundDetail`, {groupFoundId: this.data.id}).then(res=>{
			if (res.status == 1){
				this.setData({
					count: res.content.count,
					teamDetailList: res.content.contentList,
					address: res.content.address
				})
			} else {
				wx.showToast({
					title: res.msg,
					icon: "none"
				})
			}
		})
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
	
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
		return {
					title: '我正在装笆参加免费验房活动，快来和我一起吧！',
					imageUrl: this.data.picture,
					path: '/pages/team/index?groupFoundId=' + this.data.groupFoundId + '&groupActivityId=' + this.data.groupActivityId + '&isTema=' + 1 + '&leaderId=' + wx.getStorageSync('userInfo').userInfo.id
				}
  }
})